package com.thb.pay.manage.web.merchant;


import com.thb.pay.api.merchant.MchAppServiceApi;
import com.thb.pay.api.merchant.vo.req.MchAppPageReq;
import com.thb.pay.api.merchant.vo.req.MchAppReq;
import com.thb.pay.api.merchant.vo.resp.MchAppVo;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.core.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商户-应用表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@RestController
@RequestMapping("/api/sys/mchApp")
public class MchAppController {
    @Autowired
    private MchAppServiceApi mchAppServiceApi;

    @PostMapping("/list")
    public R list(@RequestBody MchAppPageReq pageReq) {
        PageResult<MchAppVo> pageResult = mchAppServiceApi.findPage(pageReq);
        return R.okData(pageResult);
    }

    @RequestMapping("/get")
    public R get(@RequestParam("id") Long id) {
        MchAppVo resultData = mchAppServiceApi.getById(id);
        return R.okData(resultData);
    }

    @PostMapping("/add")
    public R add(@RequestBody MchAppReq mchAppReq) {
        mchAppServiceApi.add(mchAppReq);
        return R.ok();
    }

    @PostMapping("/update")
    public R update(@RequestBody MchAppReq mchAppReq) {
        mchAppServiceApi.update(mchAppReq);
        return R.ok();
    }
}
